<?php

declare(strict_types=1);

namespace Plugin\Attractions\AttractionManagement\Model;

use App\Model\Attachment;
use Hyperf\DbConnection\Model\Model as MineModel;

/**
 * @property int $id 主键
 * @property string $name 点位名称
 * @property int $position_id 位置Id
 * @property int $type_id 点位类型Id
 * @property string $intro_title 点位介绍标题
 * @property string $intro 点位介绍
 * @property int $attraction_id 所属景区Id
 * @property string $cover_id 点位封面,关联attachment表
 * @property int $show_type 显示类型1:游客端显示2:管理端显示3:双端显示
 * @property int $icon_id 点位图标Id,关联attachment表
 * @property array $extension 点位扩展字段
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class AttractionSpot extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'attraction_spot';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['name', 'position_id', 'type_id', 'intro_title', 'intro', 'attraction_id', 'cover_id', 'show_type', 'icon_id', 'status', 'sort', 'extension'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'position_id' => 'integer', 'type_id' => 'integer', 'attraction_id' => 'integer', 'cover_id' => 'string', 'show_type' => 'integer', 'icon_id' => 'integer', 'status' => 'integer', 'sort', 'extension' => 'array'];

    public function position()
    {
        return $this->hasOne(AttractionSpotPosition::class, 'id', 'positionId');
    }
    
    public function type()
    {
        return $this->hasOne(AttractionType::class, 'id', 'typeId');
    }
    
    public function tags()
    {
        return $this->hasMany(AttractionSpotTag::class, 'spot_id', 'id');
    }

    public function infos()
    {
        return $this->hasMany(AttractionInfo::class, 'spot_id', 'id');
    }
}